import 'package:flutter/material.dart';

import '../../../../generated/l10n.dart';
import '../../../global/extension/int_extension.dart';
import '../../../global/uiconfig/size_fit.dart';
import '../../fliter_page/widgets/filter_page.dart';

class YSHHomePageDrawer extends StatelessWidget {
  const YSHHomePageDrawer({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: YSHSizeFit.screenWidth - 80.px,
      child: Drawer(
        child: Column(
          children: [
            _setupHeaderView(context),
            _setupListTile(const Icon(Icons.restaurant),
                S.of(context).homePageDrawerLabel_1, () {
              Navigator.of(context).pop();
            }),
            _setupListTile(
                const Icon(Icons.settings), S.of(context).homePageDrawerLabel_2,
                () {
              Navigator.of(context).pushNamed(YSHFilterPage.routeName);
            })
          ],
        ),
      ),
    );
  }

  Widget _setupHeaderView(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 120.px,
      color: Colors.orangeAccent,
      margin: EdgeInsets.only(bottom: 16.px),
      alignment: const Alignment(0, 0.75),
      child: Text(S.of(context).homePageDrawerTitle,
          style: Theme.of(context)
              .textTheme
              .headlineMedium
              ?.copyWith(fontWeight: FontWeight.bold)),
    );
  }

  Widget _setupListTile(Widget icon, String title, void Function()? handler) {
    return ListTile(
        leading: icon,
        title: Text(
          title,
          style: const TextStyle(fontWeight: FontWeight.w400, fontSize: 18.0),
        ),
        onTap: handler);
  }
}
